<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文本</title>
<link href="../../css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../js/jquery.js"></script>
  <script type="text/javascript" src="../../js/api.js"></script>
  <script type="text/javascript" src="../../js/axios.js"></script>
<script type="text/javascript">
function tipOpen(content,id,current,state,wid,oid) {
  console.log(oid)
  $("#surebtn").unbind();
  $("#surebtn").click(function () {
    var dataArr = "id="+id+"&state="+state+"&wid="+wid+"&oid="+oid;
    axiosRequest("post","/warehouse/ckUpdate",dataArr)
            .then((res)=>{
              load(current,5);
            });
    tipClose();
  });
	$(".tipright p").text(content);
	$("#tip").fadeIn(200);
}
function tipClose() {
	$("#tip").fadeOut(200);
}
</script>
</head>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>仓库管理</li>
    <li>出库管理</li>
    <li>基本内容</li>
  </ul>
</div>
<div class="rightinfo">
  <form action="" method="post" id="fo6">
    <ul class="tools">
      <li>仓库名称:
        <input type="text" name="name"/>
      </li>
      <li>订单编号:
        <input type="text" name="oid"/>
      </li>
      <li>状态:
        <select name="state">
        	<option value="0">请选择</option>
            <option value="1">未发货</option>
            <option value="2">已发货</option>
            <option value="3">已回款</option>
            <option value="4">取消订单</option>
            <option value="5">已退货</option>
        </select>
      </li>
      <li class="subBut" onclick="load(1,5)"><img src="../../images/t06.png" />查询</li>
      <li class="subBut" onclick="window.location.href='deliveryAdd.html'"><img src="../../images/t01.png" />添加出库</li>
    </ul>
    <table class="tablelist">
      <thead>
        <tr>
          <th>序号</th>
          <th>订单编号</th>
          <th>金额</th>
          <th>仓库名称</th>
          <th>出库时间</th>
          <th>出库人</th>
          <th>状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody id="body">
<!--        <tr>-->
<!--          <td>1</td>-->
<!--          <td>DJ201701270001</td>-->
<!--          <td>￥9,876,582</td>-->
<!--          <td>南京21号仓库</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>朱元璋</td>-->
<!--          <td>未发货</td>-->
<!--          <td>-->
<!--          	<a href="deliveryView.html" class="tablelink">查看详情</a>-->
<!--            <a href="javascript:void(0)" class="tablelink" onclick="tipOpen('确定此订单发货吗？')">发货</a>-->
<!--            <a href="javascript:void(0)" class="tablelink" onclick="tipOpen('确定取消此订单吗？')">取消订单</a>-->
<!--          </td>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <td>2</td>-->
<!--          <td>DJ201701270002</td>-->
<!--          <td>￥9,876,582</td>-->
<!--          <td>武汉71号仓库</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>周瑜</td>-->
<!--          <td>已发货</td>-->
<!--          <td>-->
<!--          	<a href="deliveryView.html" class="tablelink">查看详情</a> -->
<!--            <a href="javascript:void(0)" class="tablelink" onclick="tipOpen('确定取消此订单吗？')">取消订单</a>-->
<!--            <a href="javascript:void(0)" class="tablelink" onclick="tipOpen('确定收到此订单回款吗？')">确认回款</a>-->
<!--          </td>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <td>3</td>-->
<!--          <td>DJ201701270003</td>-->
<!--          <td>￥9,876,582</td>-->
<!--          <td>南京21号仓库</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>朱元璋</td>-->
<!--          <td>已回款</td>-->
<!--          <td>-->
<!--          	<a href="deliveryView.html" class="tablelink">查看详情</a>-->
<!--            <a href="javascript:void(0)" class="tablelink" onclick="tipOpen('确定取消此订单吗？')">取消订单</a>-->
<!--          </td>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <td>4</td>-->
<!--          <td>DJ201701270004</td>-->
<!--          <td>￥9,876,582</td>-->
<!--          <td>武汉71号仓库</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>周瑜</td>-->
<!--          <td>取消订单</td>-->
<!--          <td>-->
<!--          	<a href="deliveryView.html" class="tablelink">查看详情</a>-->
<!--            <a href="javascript:void(0)" class="tablelink" onclick="tipOpen('确定收到此订单的退货吗？')">确认已退货</a>-->
<!--          </td>-->
<!--        </tr>-->
<!--        <tr>-->
<!--          <td>5</td>-->
<!--          <td>DJ201701270005</td>-->
<!--          <td>￥9,876,582</td>-->
<!--          <td>南京21号仓库</td>-->
<!--          <td>2013-09-09 15:05:05</td>-->
<!--          <td>朱元璋</td>-->
<!--          <td>已退货</td>-->
<!--          <td>-->
<!--          	<a href="deliveryView.html" class="tablelink">查看详情</a>-->
<!--          </td>-->
<!--        </tr>-->
      </tbody>
    </table>
    <div class="pagin">
      <div class="message">共<i class="blue" id="total">1256</i>条记录，当前显示第&nbsp;<i class="blue" id="current">2&nbsp;</i>页</div>
      <ul class="paginList" id="page">
        <li class="paginItem"><a href="javascript:;"><span class="pagepre"></span></a></li>
        <li class="paginItem"><a href="javascript:;">1</a></li>
        <li class="paginItem current"><a href="javascript:;">2</a></li>
        <li class="paginItem"><a href="javascript:;">3</a></li>
        <li class="paginItem"><a href="javascript:;">4</a></li>
        <li class="paginItem"><a href="javascript:;">5</a></li>
        <li class="paginItem more"><a href="javascript:;">...</a></li>
        <li class="paginItem"><a href="javascript:;">10</a></li>
        <li class="paginItem"><a href="javascript:;"><span class="pagenxt"></span></a></li>
      </ul>
    </div>
  </form>
  <!-- 提示框 -->
  <div id="tip" class="tip">
    <div class="tiptop"><span>提示信息</span><a onclick="tipClose()"></a></div>
    <div class="tipinfo"> <span><img src="../../images/ticon.png" /></span>
      <div class="tipright">
        <p></p>
        <cite>如果是请点击确定按钮 ，否则请点取消。</cite> </div>
    </div>
    <div class="tipbtn">
      <input name="" type="button"  class="sure" value="确定" id="surebtn"/>
      &nbsp;
      <input name="" type="button"  class="cancel" value="取消" onclick="tipClose()" />
    </div>
  </div>
</div>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
<script type="text/javascript">
  $(function () {
    var pageNum = 1;
    var pageSize = 5;
    load(pageNum,pageSize);
  });

  function load(pageNum,pageSize) {
    var dataArr = $("#fo6").serialize()
    dataArr += "&pageNum=" + pageNum +"&pageSize="+pageSize
    axiosRequest("post", "/warehouse/ckPageBean", dataArr)
            .then((res) => {
              var lis = "";
              var state1 = "";
              var caozuo = "";
              console.log(res.data)
              for (var i = 0; i < res.data.data.length; i++) {
                if (res.data.data[i].state==1){
                  state1 = "未发货";
                  caozuo = "<a href=\"javascript:void(0)\" class=\"tablelink\" onclick=\"tipOpen('确定此订单发货吗？'"+","+res.data.data[i].id+","+res.data.pageNum+","+2+","+res.data.data[i].warehouse.id+",'"+res.data.data[i].order.orderId+"')\">发货</a>\n" +
                          "            <a href=\"javascript:void(0)\" class=\"tablelink\" onclick=\"tipOpen('确定取消此订单吗？'"+","+res.data.data[i].id+","+res.data.pageNum+","+4+")\">取消订单</a>\n" +
                          "        "
                }else if(res.data.data[i].state==2) {
                  state1 = "已发货"
                  caozuo = " <a href=\"javascript:void(0)\" class=\"tablelink\" onclick=\"tipOpen('确定收到此订单回款吗？'"+","+res.data.data[i].id+","+res.data.pageNum+","+3+")\">确认回款</a>\n" +
                          "          "
                }else if (res.data.data[i].state==3){
                  state1 = "已回款"
                  caozuo = ""
                }else if (res.data.data[i].state==4){
                  state1 = "取消订单"
                  caozuo = "<a href=\"javascript:void(0)\" class=\"tablelink\" onclick=\"tipOpen('确定收到此订单的退货吗？'"+","+res.data.data[i].id+","+res.data.pageNum+","+5+","+res.data.data[i].warehouse.id+",'"+res.data.data[i].order.orderId+"')\">确认已退货</a>\n" +
                          "          "
                }else {
                  state1 = "已退货"
                  caozuo = ""
                }
                var ls = "<tr>\n" +
                        "          <td>"+(i+1)+"</td>\n" +
                        "          <td>"+res.data.data[i].order.orderId+"</td>\n" +
                        "          <td>"+res.data.data[i].order.orderMoney+"</td>\n" +
                        "          <td>"+res.data.data[i].warehouse.cName+"</td>\n" +
                        "          <td>"+res.data.data[i].cDate+"</td>\n" +
                        "          <td>"+res.data.data[i].user.uName+"</td>\n" +
                        "          <td>"+state1+"</td>\n" +
                        "<td>\n" +
                        "\t<a href=\"deliveryView.html?orderId="+res.data.data[i].order.orderId+"\" class=\"tablelink\">查看详情</a> \n" +
                        caozuo+
                        "</td>"+
                        "        </tr>"
                lis+=ls;
              }
              $("#body").html(lis);
              $('.tablelist tbody tr:odd').addClass('odd');

              $("#total").html(res.data.totalCount)
              $("#current").html(res.data.pageNum)
              //  页码
              var begin = res.data.pageNum-1<=1?1:res.data.pageNum-1;
              var end = res.data.pageNum+1>=res.data.totalPage?res.data.totalPage:res.data.pageNum+1;
              //限制显示页码
              var pageBegin;
              var pageEnd;
              if (res.data.totalPage<6){
                pageBegin = 1;
                pageEnd = res.data.totalPage;
              }else {
                pageBegin = res.data.pageNum-3;
                pageEnd = res.data.pageNum+2;
                if (pageBegin<1){
                  pageBegin = 1;
                  pageEnd = pageBegin+5;
                }
                if (pageEnd>res.data.totalPage){
                  pageEnd = res.data.totalPage;
                  pageBegin = pageEnd-5;
                }
              }
              var lis2 = "<li class=\"paginItem\"><a href=\"javascript:;\" onclick='load("+begin+","+pageSize+")'><span class=\"pagepre\"></span></a></li>";
              for (var i = pageBegin; i <= pageEnd; i++) {
                var li;
                if (res.data.pageNum==i){
                  li = "<li class=\"paginItem current\"><a href=\"javascript:;\" onclick='load("+i+","+pageSize+")'>"+i+"</a></li>"
                }else {
                  li = " <li class=\"paginItem\"><a href=\"javascript:;\" onclick='load("+i+","+pageSize+")'>"+i+"</a></li>";
                }
                lis2+=li;
              }
              lis2+="<li class=\"paginItem\"><a href=\"javascript:;\" onclick='load("+end+","+pageSize+")'><span class=\"pagenxt\"></span></a></li>"
              $("#page").html(lis2)

            })
  }
</script>
